
uniform sampler2D textureMap;

uniform vec2 offset[9];
uniform int kernel[9];

varying vec2 texcoord; // not currently in use

void main() {

        //vec4 sum = vec4(0.0);
        float sum = 0.0;
        int i;
          
        vec4 centerColor = texture2D(textureMap, gl_TexCoord[0].st);

        for (i=0 ; i<9; i++){
            vec4 color = texture2D(textureMap, gl_TexCoord[0].st + offset[i]);
            float dist = length(color - centerColor);
            sum += 0.125*dist*kernel[i];
        } 
	gl_FragColor = vec4(sum, sum, sum, 1);
}
